<?php
/**
 * WebCms plugin
 * 
 * @package Smarty
 * @subpackage PluginsFunction
 */

/**
 * Smarty {create_url} function plugin
 * 
 * Type:     function<br>
 * Name:     create_url<br>
 * Purpose:  create normal url or friendly url<br>
 * 
 * 
 * Examples:
 * <pre>
 * {create_url com='page' a='company'*}
 * </pre>
 * 
 * @author Sérgio 'Horizak' Alves <sergioalves87@gmail.com> 
 * @version 1
 * @param array $params parameters
 * Input:<br>
 *          - loop = array whith params
 * @param object $smarty Smarty object
 * @param object $template template object
 * @return string 
 */
function smarty_function_create_url($array,$params = array()) {
  global $cms;
  $link = '';

  if ($cms->cfg['site']['fUrl']) {
    foreach ($array as $value) $link .= $value.'/';
  } else {
    $x = 'index.php?';
    foreach ($array as $k => $v) {
      $link .= $x.$k.'='.$v;
      $x = '&';
    }
  }
  return ROOT_U.$link;
}
?>
